;(function(jQuery,undefined) {
    "use strict"
    var _global,$ = jQuery;
	// 对象合并
    function extend(o,n,override) {
        for(var key in n){
            if(n.hasOwnProperty(key) && (!o.hasOwnProperty(key) || override)){
                o[key]=n[key];
            }
        }
        return o;
    }
    function compare(property,type){
	    return function(a,b){
	        var value1 = a[property];
	        var value2 = b[property];
	        if(type=='asc'){
	        	return a[property] - b[property];
	        }
	        return b[property] - a[property];
	    }
	}
    function log(m){
    	console.log(m);
    }
    function Point(x,y){this.x=x;this.y=y;}
    /**
     * @param {Object} p1
     * @param {Object} p2
     * @param {Object} p3
     * 起点P1 =（1,2）锚点P2 =（1,8）终点P3 =（10,8）
	 * 我知道在给定的时候，我知道我可以使用下面的方程来求解x和y：
	 * t = 0.5; // given example value
	 * x = (1 - t) * (1 - t) * P1.x + 2 * (1 - t) * t * P2.x + t * t * P3.x;
	 * y = (1 - t) * (1 - t) * P1.y + 2 * (1 - t) * t * P2.y + t * t * P3.y;
     */
	function Bezier(p1,p2,p3){this.p1 = p1;this.p2 = p2;this.p3 = p3;};
	/**
	 * @param {Object} p1
	 * @param {Object} p2
	 * @param {Object} p3
	 * @param {Object} y
	 * @param {Object} yl
	 */
	Bezier.prototype.getBezierX = function(y,yl){
		var t = y/yl;
		var x = (1 - t) * (1 - t) * this.p1.x + 2 * (1 - t) * t * this.p2.x + t * t * this.p3.x;
		return x;
	}
	/**
	 * @param {Object} p1
	 * @param {Object} p2
	 * @param {Object} p3
	 * @param {Object} x
	 * @param {Object} xl
	 */
	Bezier.prototype.getBezierY = function(x,xl){
		var t = x/xl;
		var y = (1 - t) * (1 - t) * this.p1.y + 2 * (1 - t) * t * this.p2.y + t * t * this.p3.y;
		return y;
	}
	//参数arr的值分别为[r,g,b]
	function rgbToHsv(arr) {
	    var h = 0, s = 0, v = 0;
	    var r = arr[0], g = arr[1], b = arr[2];
	    arr.sort(function (a, b) {
	        return a - b;
	    });
	    var max = arr[2]
	    var min = arr[0];
	    v = max / 255;
	    if (max === 0) {
	        s = 0;
	    } else {
	        s = 1 - (min / max);
	    }
	    if (max === min) {
	        h = 0;//事实上，max===min的时候，h无论为多少都无所谓
	    } else if (max === r && g >= b) {
	        h = 60 * ((g - b) / (max - min)) + 0;
	    } else if (max === r && g < b) {
	        h = 60 * ((g - b) / (max - min)) + 360;
	    } else if (max === g) {
	        h = 60 * ((b - r) / (max - min)) + 120;
	    } else if (max === b) {
	        h = 60 * ((r - g) / (max - min)) + 240;
	    }
	    h = parseInt(h);
	    s = parseInt(s * 100);
	    v = parseInt(v * 100);
	    return [h, s, v];
	}
	//参数arr的3个值分别对应[h, s, v]
	function hsvToRgb(arr) {
	    var h = arr[0], s = arr[1], v = arr[2];
	    s = s / 100;
	    v = v / 100;
	    var r = 0, g = 0, b = 0;
	    var i = parseInt((h / 60) % 6);
	    var f = h / 60 - i;
	    var p = v * (1 - s);
	    var q = v * (1 - f * s);
	    var t = v * (1 - (1 - f) * s);
	    switch (i) {
	        case 0:
	            r = v; g = t; b = p;
	            break;
	        case 1:
	            r = q; g = v; b = p;
	            break;
	        case 2:
	            r = p; g = v; b = t;
	            break;
	        case 3:
	            r = p; g = q; b = v;
	            break;
	        case 4:
	            r = t; g = p; b = v;
	            break;
	        case 5:
	            r = v; g = p; b = q;
	            break;
	        default:
	            break;
	    }
	    r = parseInt(r * 255.0);
	    g = parseInt(g * 255.0);
	    b = parseInt(b * 255.0);
	    return [r, g, b];
	}
	function rgbToYuv(arr) {
	  var R = arr[0],G = arr[1],B = arr[2];
	  var Y = 0.299*R + 0.587*G + 0.114*B;
	  var U = -0.169*R - 0.331*G + 0.500*B + 128;
	  var V = 0.500*R - 0.419*G - 0.081*B + 128;
	  return [Y, U, V];
	}
	function YuvTorgb(arr) {
	  var Y = arr[0],U = arr[1],V = arr[2];
      var R = Y + 1.403*(V-128);
	  var G = Y - 0.343(U-128) - 0.714 (V-128);
	  var B = Y + 1.770(U-128);
	  return [H, S, V];
	}
	
    String.prototype.colorRgb = function (color) {
	  // 16进制颜色值的正则
	  var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
	  // 把颜色值变成小写
	  var color = this.toLowerCase();
	  if (reg.test(color)) {
	    // 如果只有三位的值，需变成六位，如：#fff => #ffffff
	    if (color.length === 4) {
	      var colorNew = "#";
	      for (var i = 1; i < 4; i += 1) {
	        colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
	      }
	      color = colorNew;
	    }
	    // 处理六位的颜色值，转为RGB
	    var colorChange = [];
	    for (var i = 1; i < 7; i += 2) {
	      colorChange.push(parseInt("0x" + color.slice(i, i + 2)));
	    }
	    return "RGB(" + colorChange.join(",") + ")";
	  } else {
	    return color;
	  }
	};
	String.prototype.colorHex = function (color) {
	  // RGB颜色值的正则
	  var reg = /^(rgb|RGB)/;
	  var color = this;
	  if (reg.test(color)) {
	    var strHex = "#";
	    // 把RGB的3个数值变成数组
	    var colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
	    // 转成16进制
	    for (var i = 0; i < colorArr.length; i++) {
	      var hex = Number(colorArr[i]).toString(16);
	      if (hex === "0") {
	        hex += hex;
	      }
	      strHex += hex;
	    }
	    return strHex;
	  } else {
	    return String(color);
	  }
	}
	function Rgb(r,g,b){this.r = r;this.g = g;this.b = b;}
	/**
	 * @name  颜色类型【YUV】
	 * @param {Object} y
	 * @param {Object} u
	 * @param {Object} v
	 */
	function Color(){
		this.StringType = 1;//#357777
		this.RGBType = 2;//rgb(23,4,55)
		this.RGBAType = 3;//rgb(23,4,55,.5)
	}
	Color.prototype.getColorType = function(colorStr){
		colorStr = colorStr.toLowerCase();
		if(colorStr.indexOf('#')==0){
			return this.StringType;
		}else if(colorStr.indexOf('rgba')==0){
			return this.RGBAType;
		}else if(colorStr.indexOf('rgb')==0){
			return this.RGBType;
		}
		return 1;
	}
	Color.prototype.getRGB = function(colorStr){
		var type = this.getColorType(colorStr);
		if(type==this.StringType){
			colorStr = colorStr.colorRgb();
		}
		type = this.getColorType(colorStr);
		if(type==this.RGBType){
			colorStr = colorStr.colorRgb();
			return colorStr.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
		}
		return [0,0,0];
	}
	Color.prototype.getString = function(colorStr){
		var type = this.getColorType(colorStr);
		if(type==this.RGBType){
			return colorStr.colorHex();
		}
		return colorStr;
	}
	Color.prototype.RgbToHsv = function(arr){
		return rgbToHsv(arr);
	}
	Color.prototype.HsvToRgb = function(arr){
		return hsvToRgb(arr);
	}
	var colorUtil = new Color();
    var ablt_ = 'position:absolute;',relt_ = 'position:relative;',inbk = 'display:inline-block;',defaultColor='#FF0000',defaultValue = 10;
    function po(left,top){return 'left:'+left+'px;top:'+top+'px;'}
    function mg(left,top){return 'margin-left:'+left+'px;margin-top:'+top+'px;'}
    function circleTemp(r){return 'width:'+(2*r)+'px;height:'+(2*r)+'px;line-height:'+(2*r)+'px;border-radius:'+r+'px;text-align:center;'}
    function ellipseTemp(w,h){return 'width:'+w+'px;height:'+h+'px;line-height:'+h+'px;border-radius:50%;text-align:center;'}
    function cubeTemp(w,h){
    	if(w==undefined){w = 'auto';}
    	if(h==undefined){h = 'auto';}
    	if(typeof w.indexOf == 'function' && w.indexOf('auto')>-1){w = w;}else{w = w+'px';}
    	if(typeof h.indexOf == 'function' && h.indexOf('auto')>-1){h = h;}else{h = h+'px';}
    	return 'width:'+w+';height:'+h+';line-height:'+h+';text-align:center;'
    }
    function whTemp(w,h){
    	if(typeof w.indexOf == 'function' && w.indexOf('auto')>-1){w=w;}else{w=w+'px';}
    	if(typeof h.indexOf == 'function' && h.indexOf('auto')>-1){h=h;}else{h=h+'px';}
    	return 'width:'+w+';height:'+h+';';
    }
    function brTemp(br){ return 'border-radius:'+br+'px;'; }
    function bgTemp(bg){ return 'background:'+bg+';'; }
    function color(color){
    	if(color.indexOf('background')>=0){
    		return color;
    	}
    	return 'background:'+color+';';
    }
    function ladderTemp(tw,bw,h,color,bg){
    	if(tw==bw){return cubeTemp(tw,h);}
    	var minW = tw<bw?tw:bw;
    	var stl = 'width:'+minW+'px;height:0px;line-height:'+h+'px;text-align:center;';
    	var bdW = Math.abs(tw-bw)/2;
    	if(bg!=undefined){
    		stl+=bg;
    	}
    	if(tw<bw){
    		stl+='border-width: 0 '+bdW+'px '+(h+1)+'px '+bdW+'px;border-style: none solid solid;border-color: transparent transparent '+color+';';
    	}else{
    		stl+='border-top: '+(h+1)+'px solid '+color+';border-right: '+bdW+'px solid transparent;border-left: '+bdW+'px solid transparent;';
    	}
    	return stl;
    }
    function semicircleTemp(w,h,t){
    	var cott = 'width:'+w+'px;height:'+h+'px;line-height:'+h+'px;text-align:center;';
    	switch (t){
    		case 'left':
    			cott += 'border-radius: 100% 0 0 100%/50%;border-right: none;';
    			break;
    		case 'right':
    			cott += 'border-radius: 0 100% 100% 0/50%;border-left: none;';
    			break;
    		case 'bottom':
    			cott += 'border-radius: 0 0 50% 50%/0 0 100% 100%;border-top: none;';
    			break;
    		case 'top':
    		default:
    			cott += 'border-radius: 50% 50% 0 0/100% 100% 0 0;border-bottom: none;';
    			break;
    	}
    	return cott;
    }
    function circle(left,top,r,c,text,id){
    	var stl = 'style="'+ablt_+inbk+po(left,top)+circleTemp(r)+color(c)+'"';
    	return '<div '+stl+' '+(id?'id="'+id+'"':'')+'>'+text+'</div>';
    }
    function semicircle(pa,id){
    	var hml = '',c=pa.color;
    	if(pa.is3d){
    		pa.is3d = undefined;
    		hml+=semicircle(pa,id);
    		var l = pa.left,t = pa.top,w = pa.w,h = pa.h;
    		if(pa.subType=='left'){
    			w = h/6;
    			l = pa.left+pa.w-w/2;
    			pa.color = 'background-image: linear-gradient(to bottom, rgba(0,0,0,0.2) , rgba(0,0,0,0.01) );'
    		}else if(pa.subType=='top'){
    			h = w/6;
    			t = pa.top+pa.h-h/2;
    			pa.color = 'background-image: linear-gradient(to right, rgba(0,0,0,0.2) , rgba(0,0,0,0.01) );'
    		}else if(pa.subType=='right'){
    			w = h/6;
    			l = pa.left-w/2;
    			pa.color = 'background-image: linear-gradient(to bottom, rgba(0,0,0,0.2) , rgba(0,0,0,0.01) );'
    		}else{
    			h = w/6;
    			t = pa.top-h/2
    			pa.color = 'background-image: linear-gradient(to right, rgba(0,0,0,0.2) , rgba(0,0,0,0.01) );'
    		}
    		hml+=semicircle(pa,id);
    		pa.color = c;
    		hml+=ellipse(l,t,w,h,c,'');
    		if(pa.subType=='left'){
    			pa.color = 'background-image: radial-gradient(rgba(0,0,0,0), rgba(255,255,255,0.1), rgba(255,255,255,0.4));'
    		}else if(pa.subType=='top'){
    			pa.color = 'background-image: radial-gradient(rgba(0,0,0,0), rgba(255,255,255,0.1), rgba(255,255,255,0.4));'
    		}else if(pa.subType=='right'){
    			pa.color = 'background-image: radial-gradient(rgba(0,0,0,0), rgba(255,255,255,0.1), rgba(255,255,255,0.4));'
    		}else{
    			pa.color = 'background-image: radial-gradient(rgba(0,0,0,0), rgba(255,255,255,0.1), rgba(255,255,255,0.4));'
    		}
    		hml+=ellipse(l,t,w,h,pa.color,'');
    		return hml;
    	}
    	var stl = 'style="'+ablt_+inbk+po(pa.left,pa.top)+semicircleTemp(pa.w,pa.h,pa.subType)+color(pa.color)+'"';
    	return '<div '+stl+' '+(id?'id="'+id+'"':'')+'>'+pa.text+'</div>';
    }
    function cube(left,top,w,h,c,text,id,txStl){
    	var cor = c,size=14;
    	if(txStl){
	    	if(txStl.color){cor = txStl.color}
	    	if(txStl.fontSize){size = txStl.fontSize}
    	}
    	var stl = 'style="'+ablt_+inbk+((left!=undefined && top!=undefined)?po(left,top):'')+cubeTemp(w,h)+color(c)+'color:'+cor+';font-size:'+size+'px;"';
    	return '<div '+stl+' '+(id?'id="'+id+'"':'')+'>'+text+'</div>';
    }
    /**
     * @name_ 梯形
     * @param {Object} left
     * @param {Object} top
     * @param {Object} tw
     * @param {Object} bw
     * @param {Object} h
     * @param {Object} c
     * @param {Object} text
     * @param {Object} id
     */
    function ladder(left,top,tw,bw,h,c,text,id,bg){
    	text = '';
    	if(tw<bw){left=left-(bw-tw)/2;}
    	if(tw==bw){
    		return cube(left,top,tw,h+1,c,text,id);
    	}
    	var stl = 'style="'+ablt_+inbk+((left!=undefined && top!=undefined)?po(left,top):'')+ladderTemp(tw,bw,h,c,bg)+'"';
    	return '<div '+stl+' '+(id?'id="'+id+'"':'')+'>'+text+'</div>';
    }
    function svgWan(left,top,tw,bw,h,bottomH,c,tag){
		var defs ='<defs>'+
			'    <linearGradient id="svgBg" x1="0%" y1="0%" x2="100%" y2="0%">'+
			'      <stop offset="0%" style="stop-color:#000000;stop-opacity:0.3" />'+
			'      <stop offset="100%" style="stop-color:#000000;stop-opacity:0" />'+
			'    </linearGradient>'+
			'</defs>';
    	var sw = tw>bw?tw:bw,sh = h+bottomH/2;
    	if(tw<bw){
    		left -= (bw-tw)/2;
    	}
    	var hml = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="'+sw+'" height="'+sh+'" style="'+ablt_+inbk+po(left,top)+'">'
    	var stl = 'fill:url(#svgBg);';
    	if(tag){stl = 'fill:'+c+';';}
    	hml+=defs;
    	if(tw>bw){
    		hml+='<path d="M0 0 L '+tw+' 0 L '+(tw-(tw-bw)/2)+' '+h+' A'+(bw/2)+','+(bottomH/2)+' 180,0 1 '+((tw-bw)/2)+' '+h+' Z " style="'+stl+'" />';
    	}else{
    		hml+='<path d="M'+((bw-tw)/2)+' 0 L '+(bw-(bw-tw)/2)+' 0 L '+bw+' '+h+' A'+(bw/2)+','+(bottomH/2)+' 180,0 1 0 '+h+' Z " style="'+stl+'" />';
    	}
    	hml+='</svg>'
    	return hml;
    }
    function getShadow(x1b,bw,tw,y,arc){
    	var left = 0,bottom = y/8,x1 = x1b,x2 = x1b+bw;
    	var shsdw ='<defs>'+
			'    <linearGradient id="svgShadow" x1="50%" y1="0%" x2="50%" y2="100%">'+
			'      <stop offset="0%" style="stop-color:#000000;stop-opacity:0.3" />'+
			'      <stop offset="100%" style="stop-color:#000000;stop-opacity:0" />'+
			'    </linearGradient>'+
			'</defs>';
//		shsdw = '<defs>'+
//			'	<radialGradient id="svgShadow" cx="0.5" cy="0.5" r="0.7" fx="0.7" fy="0.7">'+
//			'      <stop offset="0" stop-color="rgba(0,0,0,0.5)" />'+
//			'      <stop offset="0.5" stop-color="rgba(0,0,0,0.2)" />'+
//			'      <stop offset="1" stop-color="rgba(0,0,0,0)" />'+
//	        '	</radialGradient>'+
//			'</defs>';
		var hml = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="'+(x1b+bw)+'" height="'+bottom+'" style="'+ablt_+inbk+po(0,y)+'">'
    	var stl = 'fill:url(#svgShadow);';
    	hml+=shsdw;
    	hml+='<path d="M'+(x1b)+' 0 L '+(x1b+bw)+' 0 L '+(tw)+' '+bottom+' L 0 '+bottom+' Z " style="'+stl+'" />';
//  	hml+='<ellipse cx="'+(x1b+bw/2)+'" cy="0" rx="'+(bw/2+20)+'" ry="'+(bw/2+10)+'" style="'+stl+'" />';
    	hml+='</svg>'
    	return hml;
    }
    function ladder3D(left,top,tw,bw,h,c,text,id,pa,itemData){
    	var boxW = tw>bw?tw:bw;
    	var stl_ = 'style="'+ablt_+inbk+po(left,top)+cubeTemp(boxW,h)+'opacity: 1;" ';
    	var cont = '<div '+stl_+' '+(id?'id="'+id+'"':'')+'>';
//  	cont += ladder(0,0,tw,bw,h,c,'','');
    	var topH = tw/6,bottomH = bw/13;
//  	cont += semicircle({left:(tw-bw)/2,top:h,w:bw,h:bottomH,subType:'bottom',color:c,text:''});
    	///////////////////////////////svg//////////////////////////////////////
    	cont += svgWan(0,0,tw,bw,h,bw/6,c,1);
    	if(pa.shadow){
    		cont += svgWan(0,0,tw,bw,h,bw/6,c,0);
    	}
    	////////////////////////////////////////////////////////////////////////
//  	cont += ellipse((tw-bw)/2+bw/20,h-bottomH+bottomH/3,bw-bw/10,bottomH*2-bottomH/1.5,'rgba(0,0,0,0.04)','','');
    	////////////////////////////////////////////////////////////////////////
//  	var lbgtd = 'background-image: linear-gradient(to right, rgba(0,0,0,0.3) , rgba(0,0,0,0));'
//  	cont += cube(0,0,boxW,h+bottomH,lbgtd,'','');
    	cont += ellipse(0,-topH/2,tw,topH,c,'','');
//  	var bgtd = 'background-image: linear-gradient(to right, rgba(0,0,0,0.1) , rgba(0,0,0,0.01));'
//  	cont += ellipse(0,-topH/2,tw,topH,bgtd,'','');
//  	cont += ellipse(tw/20,-topH/2+topH/10,tw-tw/10,topH-topH/5,c,'','');
    	var bgtx = 'background-image: linear-gradient(to top, rgba(0,0,0,0.5) , rgba(0,0,0,0.1) );'
    	var ix = tw-tw/10,iy = topH-topH/5;
    	if(pa.iw!=undefined){
    		if($.isArray(pa.iw) && pa.iw.length>=2){
    			if(pa.iw[0]>1){
    				ix = pa.iw[0];
    			}else{
    				ix = tw*pa.iw[0];
    			}
    			if(pa.iw[1]>1){
    				iy = pa.iw[1];
    			}else{
    				iy = topH*pa.iw[1];
    			}
    		}else{
    			if(pa.iw>1){
    				ix = pa.iw;
    				iy = pa.iw;
    			}else{
    				ix = tw*pa.iw;
    				iy = topH*pa.iw;
    			}
    		}
    	}
    	if(pa.shadow){
    		cont += ellipse((tw-ix)/2,-topH/2+(topH-iy)/2,ix,iy,bgtx,'','');
    	}
    	cont += '</div>';
    	var textLeft = 10,textTop = top+h/2,size=14,lW='auto';
    	if(pa.label && pa.label.show==true){
    		if(pa.label.style){
	    		var sty = pa.label.style;
	    		if(sty.color && sty.color!=''){
	    			c = sty.color;
	    		}
	    		if(sty.fontSize && sty.fontSize>12){
	    			size = sty.fontSize;
	    		}
	    		var marginLeft = 2;
	    		if(sty.marginLeft){
	    			marginLeft = sty.marginLeft;
	    		}
	    		if(sty.left!=undefined){
		    		if(sty.left=='left'){textLeft = marginLeft;
		    		}else if(sty.left=='right'){textLeft = left+boxW+marginLeft;
		    		}else if(sty.left=='middle'){textLeft = left+boxW/2+marginLeft;
		    		}else{textLeft = sty.left;}
	    		}
	    		if(sty.top!=undefined){
		    		if(sty.top=='top'){textTop = top+0;
		    		}else if(sty.top=='bottom'){textTop = top+h;
		    		}else if(sty.top=='middle'){textTop = top+h/2+size/2;
		    		}else{textTop = top+sty.top;}
	    		}
	    		if(sty.width){lW = sty.width;}
    		}
			if(pa.label.formatter && typeof pa.label.formatter == 'function'){
				text = pa.label.formatter(itemData);
			}
			cont += cube(textLeft,textTop,lW,0,c,text,'',{color:c,fontSize:size});
    	}
//  	console.log(cont);
    	return cont;
    } 
    /**
     * @name_ 椭圆
     * @param {Object} l
     * @param {Object} t
     * @param {Object} w
     * @param {Object} h
     * @param {Object} c
     * @param {Object} t
     * @param {Object} id
     */
    function ellipse(left,top,w,h,c,text,id,is3d){
    	var htl = '';
    	if(is3d){
    		htl+=ellipse(left,top,w,h,c,'','');
    		var bg = 'background-image: radial-gradient(rgba(255,255,255,0.8), rgba(255,255,255,0.3), rgba(255,255,255,0.1));'
    		htl+=ellipse(left,top,w,h,bg,'','');
    		return htl;
    	}
    	var stl = 'style="'+ablt_+inbk+po(left,top)+ellipseTemp(w,h)+color(c)+'"';
    	return '<div '+stl+' '+(id?'id="'+id+'"':'')+'>'+text+'</div>';
    }
    /**
     * @name_ 漏斗
     * @param {Object} left
     * @param {Object} top
     * @param {Object} tw
     * @param {Object} bw
     * @param {Object} h
     * @param {Object} color
     * @param {Object} text
     * @param {Object} data
     * @param {Object} id
     */
    function hopper(left,top,tw,bw,h,color,text,data,id,sel){
    	if(!data){data=[];}
    	try{
	    	data.sort(compare('value','desc'));
    	}catch(e){
    		console.log(e);
    	}
    	var htmlArr = [],idStr = 'Hopper'+id+'_000',html='';
    	if(data.length==1){
    		html = ladder3D(left,top,tw,bw,h,sel.colors[0],text,idStr,sel);
			htmlArr.push({
				id:idStr,
				html:html,
				data:data[0]
			});
			sel.htmlData = htmlArr;
    		return html;
    	}
    	var p1,p2,p3,gap=sel.gap!=undefined?sel.gap:10,maxW;
    	if(tw>bw){
	    	p1 = new Point(left,top);
    		if(sel.arc && sel.arc=='out'){
	    		p2 = new Point(left,top+h);
    		}else{
	    		p2 = new Point(left+(tw-bw)/2,top);
    		}
	    	p3 = new Point(left+(tw-bw)/2,top+h);
    		maxW = tw;
    	}else{
    		p1 = new Point(left+(bw-tw)/2,top);
    		if(sel.arc && sel.arc=='out'){
    			p2 = new Point(left,top);
    		}else{
    			p2 = new Point(left+(bw-tw)/2,top+h);
    		}
    		p3 = new Point(left,top+h);
    		maxW = bw;
    	}
		var bzr = new Bezier(p1,p2,p3); 
		var len = data.length;
		var itH = (h-(len-1)*gap)/len;
    	var x1,x1b;
		for (var i=0;i<data.length;i++) {
			var y1=(itH+gap)*i,y1b=y1+itH;
//			if(i==0){
				x1 = bzr.getBezierX(y1,h);
//			}else{
//				x1 = x1b;
//			}
			x1b = bzr.getBezierX(y1b,h);
			var ttw = maxW-(x1-left)*2;
			var tbw = maxW-(x1b-left)*2;
			var idStr = 'Hopper'+id+'_00'+i;
			text = data[i].name?data[i].name:text;
			if(data[i].value){text+='：'+data[i].value;}
			htmlArr.push({
				id:idStr,
				html:ladder3D(x1,y1+top,ttw,tbw,itH,sel.colors[i%sel.colors.length],text,idStr,sel,data[i]),
				data:data[i]
			});
		}
		if(sel.sun_shadow==true){
			html+= getShadow(x1b,bw,tw,top+h,45);
		}
		for(var i=htmlArr.length-1;i>=0;i--){
			html+=htmlArr[i].html;
		}
		sel.htmlData = htmlArr;
		if(htmlArr.length==0){
			var nodata = sel.noData?sel.noData:'暂无数据';
			html+='<div style="display:inline-block;position:absolute;left:0;top:50%;margin-top:-10px;width:100%;height:20px;color:#000;text-align:center;line-height:20px;font-size:16px;">'+nodata+'</div>';
		}
    	return html;
    }
    function heart(pa,id){
    	var stl = 'style="'+ablt_+inbk+po(pa.left,pa.top)+cubeTemp(pa.w,pa.h)+
    	'border:solid 0px #DDD;';
    	if(pa.animal){
    		stl+='transform-style:preserve-3d;animation:rot 10s linear infinite;';
    	}
    	stl+='"';
    	var itW = pa.w/Math.sqrt(2);
    	var itH = 5*itW/8;
    	var tranX = (itW-itH)/2;
    	var moX = tranX/Math.sqrt(2);
    	var htNum = 16,itHml='',itStl='width: '+itW+'px;height: '+itH+'px;',bw=1;
    	if(pa.n){htNum = pa.n;}
    	if(pa.borderWidth){bw=pa.borderWidth}
    	itStl+='border-radius: 50% 50% 0/50% 50% 0;border-style:solid;border-width:0 0 '+bw+'px '+bw+'px;';
    	itStl+='transform: rotate(45deg);position: absolute;left: 50%;top: 50%;margin-left:'+(-itW/2)+'px;margin-top:'+(-itH/2+moX)+'px;';
    	if(pa.background){itStl+='background:'+pa.background+';'}
    	for(var k=0;k<htNum;k++){
    		itHml+='<div style="'+itStl+'transform: rotateY('+(360*k/htNum)+'deg) rotateZ(45deg) translateX('+(-tranX)+'px);border-color:'+pa.color+';"></div>';
    	}
    	return '<div '+stl+' '+(id?'id="'+id+'"':'')+'>'+itHml+'</div>';
    }
    var regNum = /^[0-9]*$/;
    function trs_po(x,y){
    	var origin = 'transform-origin: ';
		if (regNum.test(x)) {
			origin+=x+'px ';
		}else{
			origin+=x+' ';
		}
		if (regNum.test(y)) {
			origin+=y+'px;';
		}else{
			origin+=y+';';
		}
    	return origin;
    }
    function trs_or(x,y){
    	var origin = 'transform-origin: ';
		origin+=x+'px ';
		origin+=y+'px;';
    	return origin;
    }
    function transformAngle(w,h,pa,y,z,x){
    	var rx = pa.rotateX!=undefined?pa.rotateX:80;
    	var rz = pa.rotateZ!=undefined?pa.rotateZ:10;
    	var tz = (pa.translateZ!=undefined?pa.translateZ:-h*7/10);
    	if(z!=undefined){
    		tz+=z;
    	}
    	var trX = '';
    	if(x!=undefined){
    		trX = ' translateX('+x+'px)';
    	}
    	var transform_ = 'transform: rotateX('+rx+'deg) rotateZ('+rz+'deg)'+trX+' translateY('+y+'px) translateZ('+tz+'px);';
    	if(pa.animal!=true){
    		transform_ = trs_po(0,0)+transform_;
    	}else{
    		transform_ = trs_po(x,y)+transform_;
    	}
    	return transform_;
    }
    function bg3d(w,h,pa,id){
    	var bgColor = pa.bg?pa.bg:'rgba(0,0,0,1)';
    	var stl = inbk+ablt_+mg(pa.boxLeft,0)+cubeTemp(w,h)+'border:solid 1px '+bgColor+';color:'+pa.color+';background-color: rgba(255,255,255,1);'+
    	'background-image: -webkit-linear-gradient(180deg, '+bgColor+' 1px, transparent 1px) , -webkit-linear-gradient(90deg, '+bgColor+' 1px, transparent 1px);background-size: 20px 20px;';
    	stl+=transformAngle(w,h,pa,0);
    	var bgx = '<div style="'+stl+'" id='+id+'>';
//  	if(pa.axis==true){
//  		bgx+='<div style="";></div>';
//  	}
    	bgx+='</div>'
    	return bgx;
    }
    function transform(rx,ry,rz,tx,ty,tz){
    	return 'transform: rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ('+rz+'deg) translateX('+tx+'px) translateY('+ty+'px) translateZ('+tz+'px);';
    }
    function cube3d(pa){
    	var l = pa.l,w = pa.w,h = pa.h,z = pa.z?pa.z:0;
    	var bgtx = ' linear-gradient(to top, rgba(0,0,0,0.25) , rgba(0,0,0,0.01) );';
//  	bgtx = ' radial-gradient(rgba(255,255,255,0.2), rgba(255,255,255,0.2), rgba(0,0,0,0.1));';
    	
    	pa.color = pa.colors[0];
    	var cl = 'color:'+pa.color+';';
    	var opacity = 'opacity:'+(pa.opacity?pa.opacity:1)+';';
    	var bd = 'border:solid 1px '+pa.color+';'
    	var bg = 'background:'+pa.color+bgtx+';'+opacity;
    	var styt = inbk+ablt_+cubeTemp(l,w)+po(0,0)+trs_po(l/2,w/2)+transform(0,0,0,0,0,h)+cl+bg;
    	var styb = inbk+ablt_+cubeTemp(l,w)+po(0,0)+trs_po(l/2,w/2)+transform(0,0,0,0,0,0)+cl+bg;
    	var lfb = 0, tfb = (w-h)/2;
    	var styf = inbk+ablt_+po(lfb,tfb)+cubeTemp(l,h)+trs_po(l/2,h/2)+transform(-90,0,0,0,-h/2,w/2)+cl+bg;
    	var stybk = inbk+ablt_+po(lfb,tfb)+cubeTemp(l,h)+trs_po(l/2,h/2)+transform(90,0,0,0,h/2,w/2)+cl+bg;
    	var llr = (l-w)/2, tlr = (w-h)/2;
    	var styl = inbk+ablt_+po(llr,tlr)+cubeTemp(w,h)+trs_po(w/2,h/2)+transform(0,-90,90,0,-h/2,l/2)+cl+bg;
    	var styr = inbk+ablt_+po(llr,tlr)+cubeTemp(w,h)+trs_po(w/2,h/2)+transform(0,90,90,0,h/2,l/2)+cl+bg;
    	var boxStyle = inbk+ablt_+po(pa.boxLeft,0)+transformAngle(w,pa.boxH,pa,pa.y,pa.z,pa.x)+cl+'width:'+l+'px;height:'+w+'px;transform-style: preserve-3d;z-index:1;';
    	if(pa.animal){
    		boxStyle+='animation:rot 10s linear infinite;';
    	}
    	var bgHtml = '<div type="立方体" style="'+boxStyle+'" id="'+pa.id+'">';
    	bgHtml+='<div face="上" style="'+styt+'"></div>';
    	bgHtml+='<div face="下" style="'+styb+'"></div>';
    	bgHtml+='<div face="前" style="'+styf+'"></div>';
    	bgHtml+='<div face="后" style="'+stybk+'"></div>';
    	bgHtml+='<div face="左" style="'+styl+'"></div>';
    	bgHtml+='<div face="右" style="'+styr+'"></div>';
    	bgHtml+='</div>';
    	return bgHtml;
    }
    function cylinder(pa){
    	var r = pa.r,h = pa.h,z = pa.z!=undefined?pa.z:0;
    	var l = 2*Math.PI*r,d=2*r,num=359;
    	var bgtx = ' linear-gradient(to top, rgba(0,0,0,0.35) , rgba(0,0,0,0.01) );';
 	  	bgtx = ' radial-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.3));';
    	
    	pa.color = pa.colors[0];
    	var cl = 'color:'+pa.color+';';
    	var opacity = 'opacity:'+(pa.opacity?pa.opacity:1)+';';
    	var bd = 'border:solid 1px '+pa.color+';'
    	var bg = 'background:'+pa.color+bgtx+';'+opacity;
    	var bg1 = 'background:'+pa.color+';'+opacity;
    	var boxStyle = inbk+ablt_+po(pa.boxLeft,0)+brTemp(r)+transformAngle(d,pa.boxH,pa,pa.y,pa.z,pa.x)+cl+'width:'+d+'px;height:'+d+'px;transform-style: preserve-3d;z-index:1;';
    	if(pa.animal){
    		boxStyle+='animation:rot 10s linear infinite;';
    	}
    	var bgHtml = '<div type="" style="'+boxStyle+'" id="'+pa.id+'">',rd='',wh=d,lt=-r;
    	if(pa.radius && pa.radius>0){
    		wh = d-pa.radius*2;
    		rd = 'border-top-right-radius:'+pa.radius+'px;';
    		rd += 'border-bottom-right-radius:'+pa.radius+'px;';
    		lt = -r+pa.radius;
    	}
    	var styt = inbk+ablt_+cubeTemp(wh,wh)+po(lt,lt)+trs_po(r,r)+transform(0,0,0,0,0,h)+cl+bg+brTemp(r);
    	var styb = inbk+ablt_+cubeTemp(wh,wh)+po(lt,lt)+trs_po(r,r)+transform(0,0,0,0,0,0)+cl+bg+brTemp(r);
    	bgHtml+='<div face="下" style="'+styb+'"></div>';
    	var styit;
    	for(var i=0;i<num;i++){
    		var angle = i*(360/num);
    		styit = inbk+ablt_+po(0,0)+cubeTemp(r,h)+trs_or(0,0)+transform(90,angle,0,0,0,0)+cl+bg1+rd;
    		bgHtml+='<div face="测面" style="'+styit+'"></div>';
    	}
    	bgHtml+='<div face="上" style="'+styt+'"></div>';
    	bgHtml+='</div>';
    	return bgHtml;
    }
    function lyyStyle(ls){
    	return '<style type="text/css">'+ls+'</style>';
    }
    function heartStyle(){
    	var hs = '@keyframes rot{';
	        hs+='	from{';
		    hs+='		transform:rotateX(0deg) rotateY(0deg) rotateZ(0deg);';
		 	hs+='	}';
		 	hs+='	to{';
		    hs+='		transform:rotateX(360deg) rotateY(360deg) rotateZ(360deg);';
		 	hs+='	}';
		    hs+='}';
    	return lyyStyle(hs);
    }
    function tip(da){
    	var tipHtml = '<div type="tip" style="'+inbk+ablt_+whTemp(da.w,da.h)+brTemp(da.br)
    	+bgTemp(da.bg)+'color:'+da.color+';line-height:'+da.lh
    	+'px;display:none;font-size:'+da.fontSize+'px;text-align:'+da.textAlign+';z-index:10000;" id="'+da.id+'">';
    	tipHtml+='</div>';
    	return tipHtml;
    }
    function setTipData(id,da,tipData){
    	var tp = '<div style="display:table;vertical-align:middle;padding:0;margin:'+tipData.padding+'px;">';
    	var teal = tipData.textAlign?tipData.textAlign:'right';
    	var list = da.data.list;
    	if(!list || list.length==0){
    		list = [{name:da.data.name,value:da.data.value}];
    	}
    	for (var i=0;i<list.length;i++) {
    		var it = list[i];
    		if(tipData.formatter && typeof tipData.formatter=='function'){
    			tp+=tipData.formatter(it);
    		}else{
	    		tp+='<div style="display:table-row;"><div style="display:table-cell;text-align:'+teal+';height:'+da.itH+'px;">'
	    		+it.name+'：</div><div style="display:table-cell;height:'+da.itH+'px;">'+it.value+'</div></div>';
    		}
    	}
    	tp+='</div>';
    	$('#'+id).empty();
    	$('#'+id).append(tp);
    	var h_ = list.length*da.itH+tipData.padding*2;
    	var w_ = $('#'+id).width();
    	$('#'+id).css({left:(da.l-da.bl)+'px',top:(da.t-da.bt-h_)+'px',height:h_+'px','display':'inline-block'});
    }
    // 自定义模板引擎
    function templateEngine(da) {
    	console.log(da);
    	var html='',id = genId();
    	if(!!da && da.type){
    		switch (da.type){
    			case 'circle':
		    		html=circle(da.left,da.top,da.r,da.color,da.text,id);
    				break;
    			case 'semicircle':
		    		html=semicircle(da,id);
    				break;
    			case 'ladder':
		    		html=ladder(da.left,da.top,da.tw,da.bw,da.h,da.color,da.text,id);
    				break;
				case 'ellipse':
					html=ellipse(da.left,da.top,da.w,da.h,da.color,da.text,id,da.is3d);
					break;
				case 'hopper':
					html=hopper(da.left,da.top,da.tw,da.bw,da.h,da.color,da.text,da.data,id,da);
					break;
				case 'heart':
					html=heart(da,id);
					break;
				case 'tip':
					html=tip(da);
					break;
				case 'cube':
					da.id = id;
					html=cube3d(da);
					break;
				case 'cylinder':
					da.id = id;
					html=cylinder(da);
					break;
    			default:
    				break;
    		}
    		if(!da.id)da.id = id;
    	}
    	return html;
    }
    function genId(){return ('ID_'+Math.random(100000000)).replace('.','_');}
    function Graph(dom,param){
    	this.w = $('#'+dom).width(),this.h = $('#'+dom).height();
    	this.id = genId();
    	this.tipId = genId();
    	this.tipData=undefined;
    	this.param=param;
    	this.dom=dom;
		$('#'+dom).append(cube(undefined,undefined,this.w,this.h,'#FFFFFF','',this.id));
    	this.bl = document.getElementById(dom).getBoundingClientRect().left;
    	this.bt = document.getElementById(dom).getBoundingClientRect().top;
    	this.isinit = false;
    };
    Graph.prototype={
    	_init:function(pa){
    		pa.boxW = this.w;
    		pa.boxH = this.h;
    		var rz = pa.rotateZ!=undefined?pa.rotateZ:10;
    		this.boxLeft = pa.boxW*(rz/90);//Math.abs(pa.boxW*Math.sin(rz))/3
	    	if(pa.is3d==true){
    			pa.boxLeft = this.boxLeft;
	    		$('#'+this.id).css({'background':'#000000'});
	    		$('#'+this.dom).append(bg3d(this.w,this.h,pa,genId()));
	    	}
	    	this.isinit = true;
    	},
    	_setup:function(pa){
    		pa.boxLeft = this.boxLeft;
    	},
    	_parseParam:function(pa){
    		if(this.isinit==false){this._init(pa);}
    		this._setup(pa);
    		if(!!pa.type){
    			switch (pa.type){
    				case 'circle':
    					if(!pa.left){pa.left=0;}
    					if(!pa.top){pa.top=0;}
    					if(!pa.r || pa.r<=0){pa.r=defaultValue;}
    					if(!pa.color){pa.color=defaultColor;}
    					if(!pa.text){pa.text='';}
    					this._drawImage(pa);
    					break;
    				case 'semicircle':
    					if(!pa.left){pa.left=0;}
    					if(!pa.top){pa.top=0;}
    					if(!pa.w || pa.w<=0){pa.w=defaultValue;}
    					if(!pa.h || pa.h<=0){pa.h=defaultValue;}
    					if(!pa.subType || 'left,top,right,bottom'.indexOf(pa.subType)<0){pa.subType='top';}
    					if(!pa.color){pa.color=defaultColor;}
    					if(!pa.text){pa.text='';}
    					this._drawImage(pa);
    					break;
					case 'ladder':
    					if(!pa.left){pa.left=0;}
    					if(!pa.top){pa.top=0;}
    					if(!pa.tw || pa.tw<=0){pa.tw=defaultValue;}
    					if(!pa.bw || pa.bw<=0){pa.bw=defaultValue;}
    					if(!pa.h || pa.h<=0){pa.h=defaultValue;}
    					if(!pa.color){pa.color=defaultColor;}
    					if(!pa.text){pa.text='';}
    					this._drawImage(pa);
						break;
    				case 'ellipse':
    					if(!pa.left){pa.left=0;}
    					if(!pa.top){pa.top=0;}
    					if(!pa.w || pa.w<=0){pa.w=defaultValue;}
    					if(!pa.h || pa.h<=0){pa.h=defaultValue;}
    					if(!pa.color){pa.color=defaultColor;}
    					if(!pa.text){pa.text='';}
    					this._drawImage(pa);
    					break;
					case 'hopper':
    					if(!pa.left){pa.left=0;}
    					if(!pa.top){pa.top=0;}
    					if(!pa.tw || pa.tw<=0){pa.tw=defaultValue;}
    					if(!pa.bw || pa.bw<=0){pa.bw=defaultValue;}
    					if(!pa.h || pa.h<=0){pa.h=defaultValue;}
    					if(!pa.color){pa.color=defaultColor;}
    					if(!pa.text){pa.text='';}
    					this._drawImage(pa);
						break;
					case 'heart':
    					if(!pa.left){pa.left=0;}
    					if(!pa.top){pa.top=0;}
    					if(!pa.tw || pa.tw<=0){pa.tw=defaultValue;}
    					if(!pa.bw || pa.bw<=0){pa.bw=defaultValue;}
    					if(!pa.h || pa.h<=0){pa.h=defaultValue;}
    					if(!pa.color){pa.color=defaultColor;}
    					if(!pa.text){pa.text='';}
    					this._drawImage(pa);
						break;
					case 'cube':
    					if(!pa.left){pa.left=0;}
    					if(!pa.top){pa.top=0;}
    					if(!pa.w || pa.w<=0){pa.w=defaultValue;}
    					if(!pa.l || pa.l<=0){pa.l=defaultValue;}
    					if(!pa.h || pa.h<=0){pa.h=defaultValue;}
    					if(pa.x==undefined){pa.x=0;}
    					if(pa.y==undefined){pa.y=0;}
    					if(pa.z==undefined){pa.z=0;}
    					if(!pa.color){pa.color=defaultColor;}
    					if(!pa.text){pa.text='';}
    					this._drawImage(pa);
						break;
					case 'cylinder':
						if(pa.left==undefined){pa.left=0;}
						if(pa.top==undefined){pa.top=0;}
						if(pa.r==undefined){pa.l=defaultValue;}
						if(pa.h==undefined){pa.h=defaultValue;}
						if(pa.x==undefined){pa.x=0;}
						if(pa.y==undefined){pa.y=0;}
						if(pa.z==undefined){pa.z=0;}
						if(!pa.color){pa.color=defaultColor;}
						if(!pa.text){pa.text='';}
						this._drawImage(pa);
						break;
    				default:
    					break;
    			}
    		}
    	},
    	_drawImage:function(pa){
    		switch (pa.type){
				case 'circle':this._drawCircle(pa);break;
				case 'semicircle':this._drawSemicircle(pa);break;
				case 'ladder':this._drawLadder(pa);break;
				case 'ellipse':this._drawEllipse(pa);break;
				case 'hopper':this._drawHopper(pa);break;
				case 'heart':this._drawHeart(pa);break;
				case 'cube':this._drawCube(pa);break;
				case 'cylinder':this._drawCylinder(pa);break;
				default:break;
			}
    		if(pa.bg && pa.is3d==false){$('#'+this.id).css({'background':pa.bg});}
    		if(pa.border){$('#'+this.id).css({'border':pa.border});}
    		if(pa.tip && pa.tip.show==true){
    			var tipStyle={};
    			if(pa.tip.style){
    				tipStyle = pa.tip.style;
    			}
				var fs = tipStyle.fontSize?tipStyle.fontSize:14;
				var lh = tipStyle.lineHeight?tipStyle.lineHeight:(fs+6);
				var pd = tipStyle.padding?tipStyle.padding:6;
				var tWidth = tipStyle.width?tipStyle.width:'auto';
				var tHeight = tipStyle.height?tipStyle.height:pa.data.length*lh+pd*2;
				var bgC = tipStyle.background?tipStyle.background:'rgba(0,0,0,0.6)';
				var idStr = this.tipId;
				var corner = tipStyle.borderRadius?tipStyle.borderRadius:'0';
				var c = tipStyle.color?tipStyle.color:'#FFFFFF';
				var tali = tipStyle.textAlign?tipStyle.textAlign:'left';
				this.tipData = {
					type:'tip',w:tWidth,h:tHeight,bg:bgC,id:idStr,br:corner,padding:pd,color:c,lh:lh,
					data:pa.data,fontSize:fs,textAlign:tali,formatter:pa.tip.formatter
				};
				$('#'+this.id).append(templateEngine(this.tipData));
    		}
    	},
    	_drawCircle:function(pa){//圆形
    		$('#'+this.id).append(templateEngine(pa));
    		if(!!pa.fn && typeof pa.fn=='function'){
    			$('#'+pa.id).on('click',function(){
					pa.fn($(this).html());
				});
			}
    	},
    	_drawSemicircle:function(pa){//半圆形
    		$('#'+this.id).append(templateEngine(pa));
    		if(!!pa.fn && typeof pa.fn=='function'){
    			$('#'+pa.id).on('click',function(){
					pa.fn($(this).html());
				});
			}
    	},
    	_drawLadder:function(pa){//梯形
    		$('#'+this.id).append(templateEngine(pa));
    		if(!!pa.fn && typeof pa.fn=='function'){
    			$('#'+pa.id).on('click',function(){
					pa.fn($(this).html());
				});
			}
    	},
    	_drawEllipse:function(pa){//椭圆
    		$('#'+this.id).append(templateEngine(pa));
    		if(!!pa.fn && typeof pa.fn=='function'){
    			$('#'+pa.id).on('click',function(){
					pa.fn($(this).html());
				});
			}
    	},
    	_drawHopper:function(pa){//漏斗
    		$('#'+this.id).append(templateEngine(pa));
    		if(pa.htmlData){
    			var self = this;
    			var lh = 20;
    			if(pa.tip && pa.tip.style && pa.tip.style.lineHeight){
    				lh = pa.tip.style.lineHeight;
    			}
    			for(var o=0;o<pa.htmlData.length;o++){
    				const im = o;
    				const hd = pa.htmlData[im];
    				if(!!pa.fn && typeof pa.fn=='function'){
	    				$('#'+hd.id).on('click',function(){
	    					pa.fn(im,pa.htmlData);
	    				});
    				}
    				$('#'+hd.id).hover(function(){
					    $('#'+hd.id).css({'transform':'scale(1.1)'});
					},function(){
					    $('#'+hd.id).css({'transform':'scale(1.0)'});
					    $('#'+self.tipId).css({'display':'none'});
					});
					if(pa.tip && pa.tip.show==true){
						$('#'+hd.id).mousemove(function(e){
							if(!self.tipData)return;
//							log(e);
							var sTop = 0;
							var sLeft = 0;
							try{
								sTop = document.getElementById(this.param.scrollBox).scrollTop;
								sLeft = document.getElementById(this.param.scrollBox).scrollLeft;
							}catch(e){
								//TODO handle the exception
							}
							setTipData(self.tipId,{l:e.pageX,t:e.pageY,itH:lh,data:hd.data,bl:self.bl-sLeft,bt:self.bt-sTop},self.tipData);
						});
					}
    			}
    		}
    	},
    	_drawHeart:function(pa){//心形
    		$('head').append(heartStyle());
    		$('#'+this.id).append(templateEngine(pa));
    		
    	},
    	_drawCube:function(pa){//立方体
    		$('head').append(heartStyle());
    		$('#'+this.id).append(templateEngine(pa));
    	},
    	_drawCylinder:function(pa){//圆柱
    		$('head').append(heartStyle());
    		$('#'+this.id).append(templateEngine(pa));
    	},
    	_clearDom:function(){
    		$('#'+this.id).empty();
    	}
    }
    function Lyy(dom){
    	this._initial(dom);
    }
    Lyy.prototype = {
    	constructor:this,
    	_initial:function(dom){
    		this.dom_ = dom;
    		// 默认参数
            this.param_ = {
            	type:'circle',
                colors: ['#ff9915','#ffdb15','#baff15','#46e621','#00df93','#00addf','#1a86ff','#8e49ff','#ff49f9','#fd8c8c'],
                left:0,
                top:0,
                color:defaultColor,
                text:'',
                shadow:true,
                animal:false,
                is3d:true,
                scrollBox:'right-content'
            };
    		this.graph_ = new Graph(this.dom_,this.param_);
    	},
    	setParam:function(param){
            this.param_ = extend(this.param_,param,true); //配置参数
            this.clear();
            this.graph_._parseParam(this.param_);
    	},
    	addObject:function(obj){
    		this.graph_._parseParam(extend(this.param_,obj,true));
    	},
    	clear:function(){
            this.graph_._clearDom();
    	}
    }
    _global = (function(){ return this || (0, eval)('this'); }());
    if (typeof module !== "undefined" && module.exports) {
        module.exports = Lyy;
    } else if (typeof define === "object" && define.amd) {
        define(function(){return Lyy;});
    } else {
        !('Lyy' in _global) && (_global.Lyy = Lyy);
    }
}(jQuery));